<?php
mysql_query("SET character_set_results=utf8");
class Mon_model extends CI_Model {

    private $tbl_mon= 'mon';

    function __construct(){
        parent::__construct();
    }

    public function getMon(){
        $this->db->select('*');
        $result = $this->db->get('mon');
        return $result;
        $result->free_result();
    }
    function list_all(){
        $this->db->order_by('id','asc');
        return $this->db->get($tbl_mon);
    }

    function count_all(){
        return $this->db->count_all($this->tbl_mon);
    }

    function get_paged_list($limit = 10, $offset = 0){
        $this->db->order_by('id','asc');
        return $this->db->get($this->tbl_mon, $limit, $offset);
    }

    function get_by_id($id){
        $this->db->where('id', $id);
        return $this->db->get($this->tbl_mon);
    }

    function save($data){
        $this->db->insert($this->tbl_mon, $data);
        return $this->db->insert_id();
    }

    function update($id, $data){
        $this->db->where('id', $id);
        $this->db->update($this->tbl_mon, $data);
    }

    function delete($id){
        $this->db->where('id', $id);
        $this->db->delete($this->tbl_mon);
    }
}
?>